package com.udian.frame.code;

public class Column{
	
	/**
	 * 名称
	 */
	private String name;
	
	/**
	 * 类型
	 */
	private String type;
	
	/**
	 * 说明
	 */
	private String comment;
	
	/**
	 * 长度
	 */
	private Integer length;
	
	/**
	 * 是否可以为空  true：可以
	 */
	private boolean flag;
	
	/**
	 * 最大长度
	 */
	private String maxLength;
	
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public Integer getLength() {
		return length;
	}

	public void setLength(Integer length) {
		this.length = length;
	}

	public String getAlias() {
		return CamelUtil.underlineToCamel(name.replace("tbl_base_", ""));
	}
	
	
	public String getAliasMethod() {
		String alias = CamelUtil.underlineToCamel(name.replace("tbl_base_", ""));
		return alias.substring(0,1).toUpperCase() + alias.substring(1, alias.length());
	}
	
	
	public String getJavaType() {
		if("varchar".equals(type)){
			return "String";
		}
		if("bigint".equals(type)){
			return "Long";
		}
		
		if("tinyint".equals(type)){
			return "Integer";
		}
		
		if("int".equals(type)){
			return "Integer";
		}
		
		if("datetime".equals(type)){
			return "Date";
		}
		
		if("date".equals(type)){
			return "Date";
		}
		
		if("text".equals(type)){
			return "String";
		}
		
		if("decimal".equals(type)){
			return "BigDecimal";
		}
		
		if("double".equals(type)){
			return "Double";
		}
		
		if("float".equals(type)){
			return "Double";
		}
		
		if("time".equals(type)){
			return "Date";
		}
		return type;
	}
	
	
	public String getXiaoYaoJiType() {
		if("varchar".equals(type)){
			return "string";
		}
		if("bigint".equals(type)){
			return "number";
		}
		
		if("tinyint".equals(type)){
			return "number";
		}
		
		if("int".equals(type)){
			return "number";
		}
		
		if("datetime".equals(type)){
			return "string";
		}
		
		if("date".equals(type)){
			return "string";
		}
		
		if("text".equals(type)){
			return "string";
		}
		
		if("decimal".equals(type)){
			return "number";
		}
		
		if("double".equals(type)){
			return "number";
		}
		
		if("float".equals(type)){
			return "number";
		}
		
		if("time".equals(type)){
			return "string";
		}
		return type;
	}
	
	
	
	@Override
	public String toString() {
		return "Colume [name=" + name + ", type=" + type + ", comment=" + comment + ", length=" + length + "]";
	}


	public String getMaxLength() {
		return maxLength;
	}

	public void setMaxLength(String maxLength) {
		this.maxLength = maxLength;
	}

	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	
	
	
	
	
}